﻿@{
    ViewBag.Title = "角色列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model RoleQueryModel
<div class="row">
    <div class="panel panel-default">
        <div class="panel-body">
            <form class="form-inline" role="form" id="searchForm">
            <div class="form-group input-group-sm">
                <label for="name">
                    名称：</label>
                @Html.TextBoxFor(m => m.RoleName, new { @class = "form-control", placeholder = "输入角色名称" })
            </div>
            <label>
                创建日期：</label>
            <div class="form-group">
                <div class="input-group input-daterange input-group-sm">
                    @Html.TextBoxFor(m => m.StartTime, new { @class = "form-control datepicker", placeholder = "起始时间" })
                    <span class="input-group-addon">到</span>
                    @Html.TextBoxFor(m => m.EndTime, new { @class = "form-control datepicker", placeholder = "结束时间" })
                </div>
            </div>
             @Html.Partial("UC_Button", ViewBag.ButtonList as List<Sys_Menu>)
            </form>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-body">
            <table id="flexigridData">
            </table>
        </div>
    </div>
</div>
@section Customer_Js
{
    <script type="text/javascript">
        function flexiQuery() {
           $('#flexigridData').bootstrapTable('refresh');
        };

        function addRole(){
            window.location.href = '@Url.Action("Add", "Role")';
            return false;
        }

        function editRole() {
            var row = $('#flexigridData').bootstrapTable('getSelections');
            if (row == null || row.length == 0) {
                BootStrapUI_Core.alertError('请选择需要编辑的行');
            } else {
                window.location.href = '@Url.Action("Edit", "Role")?id=' + row[0].Id;
            }
            return false;
        }

        function delRole(){
            var row = $('#flexigridData').bootstrapTable('getSelections');
            if (row == null || row.length == 0) {
                BootStrapUI_Core.alertError('请选择需要编辑的行');
            } else {
                postAjax('@Url.Action("Delete", "Role")',{ id: row[0].Id },'是否确认删除');
            }
            return false;
        }

        function editRoleDistributionAction(){
            var row = $('#flexigridData').bootstrapTable('getSelections');
            if (row == null || row.length == 0) {
                BootStrapUI_Core.alertError('请选择需要分配权限的角色');
            } else {
                window.location.href = '@Url.Action("DistributionAction", "Role")?id=' + row[0].Id;
            }
            return false;
        }

        $(function () {
            $('#btnQuery').on('click', flexiQuery);
            $('#btnRoleAdd').on('click',addRole);
            $('#btnRoleEdit').on('click', editRole);
            $('#btnRoleDelete').on('click', delRole);
            $('#btnRoleDistributionAction').on('click',editRoleDistributionAction);
            btTable('#flexigridData', {
                title: '角色列表',
                url: '@Url.Action("AjaxIndex", "Role")',
                columns: [[
                    { field: 'rowscount', checkbox: true, width:15 },
                    { field: 'RoleName', title: '角色名称', width: 100 },
                    { field: 'CreateTime', title: '创建时间', width: 200 },
                ]],
            });
            
        })
    </script>
}
